<template>
	<view class="preview-imgs" @click="previewClick" data-class="preview">
		<swiper class="swiper" circular indicator-dots indicator-color="#fff">
			<swiper-item v-for="(img,index) in imgList" :key="index" class="swiper-item">
				<image class="img" :src="img" mode="widthFix"></image>
			</swiper-item>
		</swiper>
	</view>
</template>

<script setup>
	const emits = defineEmits(['closePreview'])
	defineProps({
		imgList: {
			type: Array,
			default: []
		}
	})
	const previewClick = (e) => {
		if (e.target.dataset.class === "preview") {
			emits('closePreview')
		}
	}
</script>

<style lang="scss">
	.preview-imgs {
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		height: 100vh;
		background-color: rgba(0, 0, 0, .5);
		z-index: 99;
		display: flex;
		justify-content: center;
		align-items: center;

		.swiper {
			width: 90%;
			height: 500rpx;

			.swiper-item {
				width: 100%;
				height: 100%;

				.img {
					width: 100%;
				}
			}
		}
	}
</style>